#pragma once
#include "tlv_buffer.h"
#include <unordered_map>
#include <vector>
#include <optional>

class TLVParser {
public:
    explicit TLVParser(const TLVBuffer& buffer);

    bool parse(); // 扫描并分类所有 TLV 项

    std::vector<TLV> getByType(TLVType type) const;
    std::optional<TLV> getFirst(TLVType type) const;

private:
    const TLVBuffer& buffer_;
    std::unordered_map<TLVType, std::vector<TLV>> classified_;
};